package com.googlecode.spruce.dao.impl;

import org.hibernate.Hibernate;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.googlecode.spruce.dao.AbstractDao;
import com.googlecode.spruce.dao.ServiceGroupScheduleDao;
import com.googlecode.spruce.domain.ServiceGroupSchedule;

@Repository(value = "serviceGroupScheduleDao")
@Transactional
public class DefaultServiceGroupScheduleDao extends AbstractDao<Integer, ServiceGroupSchedule> implements
        ServiceGroupScheduleDao
{

    public DefaultServiceGroupScheduleDao()
    {
        super(ServiceGroupSchedule.class);
    }

    public ServiceGroupSchedule findByIDInitialized(final Integer id)
    {
        final ServiceGroupSchedule item = super.findByID(id);

        Hibernate.initialize(item.getServiceGroup().getService());
        Hibernate.initialize(item.getServiceGroup().getServiceGroupSchedules());

        return item;
    }

}
